package com.bytecamp.testplatform.controller;


import com.bytecamp.testplatform.model.TestCase;
import com.bytecamp.testplatform.service.TestCaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

// TestCaseController.java 修正后
@RestController
@RequestMapping("/api/cases")
@Tag(name = "测试用例管理", description = "生成、查询测试用例")
@RequiredArgsConstructor
public class TestCaseController {

    private final TestCaseService testCaseService; // 只依赖Service

    // 生成用例接口（不变）
    @PostMapping("/generate")
    @Operation(summary = "生成测试用例")
    public String generateTestCase(@RequestParam Long apiId) {
        return testCaseService.generateAndSave(apiId);
    }

    // 查询用例接口（修正：调用Service）
    @GetMapping("/list")
    @Operation(summary = "查询用例列表")
    public List<TestCase> getCaseList(@RequestParam(required = false) Long apiId) {
        return testCaseService.getCaseList(apiId); // 调用Service方法
    }
}
